Skip to content

KAFKA-6342: Move workaround for JSON parsing of non-escaped strings#8591

Merged
hachikuji merged 13 commits into
apache:trunkfrom
viktorsomogyi:KAFKA-6342
May 6, 2020
Merged

KAFKA-6342: Move workaround for JSON parsing of non-escaped strings#8591
hachikuji merged 13 commits into
apache:trunkfrom
viktorsomogyi:KAFKA-6342

Conversation

@viktorsomogyi

Copy link
Copy Markdown
Contributor

PR #4303 introduced parsing for some invalid JSONs, such as escaped SSL names. This PR moves the parsing directly under AclEntry to localize this logic.

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just a nit below. Also, the diff is showing TopicCount with no changes. Do you know what that's about?

Comment thread core/src/main/scala/kafka/security/authorizer/AclEntry.scala Outdated
@ijuma

ijuma commented Apr 30, 2020

Copy link
Copy Markdown
Member

ok to test

@viktorsomogyi

Copy link
Copy Markdown
Contributor Author

Removed TopicCount. That was probably a leftover from the rebase, I guess the merge tool didn't delete it correctly or something.

@ijuma

ijuma commented May 1, 2020

Copy link
Copy Markdown
Member

ok to test

@ijuma

ijuma commented May 1, 2020

Copy link
Copy Markdown
Member

retest this please

1 similar comment
@hachikuji

Copy link
Copy Markdown
Contributor

retest this please

Comment thread core/src/test/scala/unit/kafka/security/authorizer/AclEntryTest.scala Outdated
@@ -35,16 +35,7 @@ object Json {
*/
def parseFull(input: String): Option[JsonValue] =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably missing something obvious, but I found the following callers of this function: DeleteRecordsCommand, LeaderElectionCommand, PreferredReplicaLeaderElectionCommand, and ReassignPartitionsCommand. As far as I can tell, none of these uses involve the parsing of ACLs. Did we lose this compatibility handling at some point or is there some magic invocation?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compatibility fix was only required for ACLs, but we added it here to keep the fix small for backporting. The idea was to move to the appropriate place soon after, but it got stuck for a while. Do you have some concerns?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed this offline with @hachikuji. I had misunderstood his point. It looks like the compatibility code has not been used since 1.1.0:

9b44c3e#diff-81f2ec590f4e047be7e3a7e5267cbc9aR60

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we should just drop this code.

@viktorsomogyi viktorsomogyi May 5, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looks like parseFull is used in a couple of places as Json mentioned but I can perhaps just delegate this to parseBytes like this below and can continue using that in the mentioned callers.

def parseFull(input: String): Option[JsonValue] = parseBytes(input.getBytes(Charset.defaultCharset()))

Or shall I just get rid of this code and use parseBytes everywhere?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is fine as it is. We are suggesting that we don't need parseBytesWithAclFallback in AclEntry.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then I misunderstood it too. :)
However isn't it possible that this issue resurfaces again if we remove this? I suspect the user who raised it may still use 1.0 where it got fixed and when they upgrade they'd run into this again. Or am I missing something else too?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@viktorsomogyi I think the argument is that if no-one complained since 1.1 which was released more than 2 years ago, then maybe this issue is very rare.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, that's fair. I've uploaded the changes.

@hachikuji

Copy link
Copy Markdown
Contributor

retest this please

2 similar comments
@hachikuji

Copy link
Copy Markdown
Contributor

retest this please

@hachikuji

Copy link
Copy Markdown
Contributor

retest this please

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (assuming tests are passing)

@ijuma ijuma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM too.

@hachikuji
hachikuji merged commit d70dacb into apache:trunk May 6, 2020
@viktorsomogyi

Copy link
Copy Markdown
Contributor Author

Thank you guys for the review!

@viktorsomogyi
viktorsomogyi deleted the KAFKA-6342 branch May 7, 2020 13:22
Kvicii pushed a commit to Kvicii/kafka that referenced this pull request May 7, 2020
* 'trunk' of github.com:apache/kafka: (87 commits)
  KAFKA-9865: Expose output topic names from TopologyTestDriver (apache#8483)
  MINOR - Increase the number of Trogdor Histogram buckets to 10000 (apache#8627)
  KAFKA-9768: Fix handling of rest.advertised.listener config (apache#8360)
  KAFKA-9419: Fix possible integer overflow in CircularIterator (apache#7950)
  MINOR: Only add 'Data' suffix for generated request/response/header types (apache#8625)
  KAFKA-9947; Ensure proper shutdown of services in `TransactionsBounceTest` (apache#8602)
  KAFKA-6342; Remove unused workaround for JSON parsing of non-escaped strings (apache#8591)
  MINOR: Pass `-release 8` to scalac and upgrade to Gradle 6.4 (apache#8538)
  KAFKA-9946; Partition deletion event should only be sent if deletion was requested in the StopReplica request (apache#8609)
  MINOR: Improve TopologyTestDriver JavaDocs (apache#8619)
  MINOR: MockAdminClient should return InvalidReplicationFactorException if brokers.size < replicationFactor
  KAFKA-9748: Add Streams eos-beta integration test (apache#8496)
  KAFKA-9731: Disable immediate fetch response for hw propagation if replica selector is not defined (apache#8607)
  HOTFIX: set correct numIterations in shouldAllowConcurrentAccesses
  MINOR: Clean up some test dependencies on ConfigCommand and TopicCommand (apache#8527)
  KAFKA-9918; SslEngineFactory is NOT closed when channel is closing (apache#8551)
  KAFKA-9798: Send one round synchronously before starting the async producer (apache#8565)
  MINOR: Annotate KafkaAdminClientTest.testAlterClientQuotas() with @test
  KAFKA-9589: Enable testLogAppendTimeNonCompressedV2 and fix bug in helper method (apache#8533)
  MINOR: Use min/max function when possible (apache#8577)
  ...

# Conflicts:
#	core/src/main/scala/kafka/log/Log.scala
#	gradle/dependencies.gradle
#	gradle/wrapper/gradle-wrapper.properties
#	gradlew
jwijgerd pushed a commit to buxapp/kafka that referenced this pull request May 14, 2020
…strings (apache#8591)

Previously we had fallback logic when parsing ACLs to handle older entries which may contain non-escaped characters. This code became dead after 1.1 since it was no longer used in the parsing of ACLs. This patch removes the fallback logic.

Reviewers: Ismael Juma <ismael@juma.me.uk>, Jason Gustafson <jason@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants